package com.lxmes.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.pm.domain.AProjectChange;
import com.lxmes.pm.service.IAProjectChangeService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 项目转化Controller
 * 
 * @author zhangzhiyu
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/pm/projectChange")
public class AProjectChangeController extends BaseController
{
    @Autowired
    private IAProjectChangeService aProjectChangeService;

    /**
     * 查询项目转化列表
     */
    @PreAuthorize("@ss.hasPermi('pm:projectChange:list')")
    @GetMapping("/list")
    public TableDataInfo list(AProjectChange aProjectChange)
    {
        startPage();
        List<AProjectChange> list = aProjectChangeService.selectAProjectChangeList(aProjectChange);
        return getDataTable(list);
    }

    /**
     * 导出项目转化列表
     */
    @PreAuthorize("@ss.hasPermi('pm:projectChange:export')")
    @Log(title = "项目转化", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AProjectChange aProjectChange)
    {
        List<AProjectChange> list = aProjectChangeService.selectAProjectChangeList(aProjectChange);
        ExcelUtil<AProjectChange> util = new ExcelUtil<AProjectChange>(AProjectChange.class);
        util.exportExcel(response, list, "项目转化数据");
    }

    /**
     * 获取项目转化详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:projectChange:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aProjectChangeService.selectAProjectChangeById(id));
    }

    /**
     * 新增项目转化
     */
    @PreAuthorize("@ss.hasPermi('pm:projectChange:add')")
    @Log(title = "项目转化", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AProjectChange aProjectChange)
    {
        return toAjax(aProjectChangeService.insertAProjectChange(aProjectChange));
    }

    /**
     * 修改项目转化
     */
    @PreAuthorize("@ss.hasPermi('pm:projectChange:edit')")
    @Log(title = "项目转化", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AProjectChange aProjectChange)
    {
        return toAjax(aProjectChangeService.updateAProjectChange(aProjectChange));
    }

    /**
     * 删除项目转化
     */
    @PreAuthorize("@ss.hasPermi('pm:projectChange:remove')")
    @Log(title = "项目转化", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aProjectChangeService.deleteAProjectChangeByIds(ids));
    }
}
